﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BlueLotus7.Common
{
    public class PersonIdentity : IValidate
    {
        #region Fields

        protected string displayName;
        protected Guid? key;
        protected string loginId;
        protected long? aliaId;

        #endregion

        #region

        public string DisplayName
        {
            get { return displayName; }
            set { displayName = value; }
        }

        public Guid? Key
        {
            get { return key; }
            set { key = value; }
        }

        public string LoginId
        {
            get { return loginId; }
            set { loginId = value; }
        }

        public long? AliaId
        {
            get { return aliaId; }
            set { aliaId = value; }
        }

        #endregion

        #region Constructor

        public PersonIdentity() { }
        public PersonIdentity(Guid? key)
        {
            this.key = key;
        }

        #endregion

        #region IValidate Members

        public bool IsValid
        {
            get
            {
                try
                {
                    Validate();
                    return true;
                }
                catch
                {
                    return false;
                }
            }
        }

        public void Validate()
        {
            if (string.IsNullOrWhiteSpace(displayName))
            {
                throw new NullReferenceException("displayName");
            }
        }

        #endregion
    }
}
